package xrz.xuanbao.modular.mine.myshoucang;

import java.util.Date;

import org.xutils.x;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ProgressBar;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;
import xrz.cuanbao.R;
import xrz.cuanbao.utils.DateKit;
import xrz.xuanbao.modular.paipaibao.Act_PaipaibaoDetail;

public class Adapter_ShangPin extends QuickAdapter<ShangpinShoucang> {

	public Adapter_ShangPin(Context context, int layoutResId) {
		super(context, layoutResId);
		// TODO Auto-generated constructor stub
	}

	// @Override
	// protected View getExView(int position, View view, ViewGroup parent) {
	// view = LayoutInflater.from(ctx).inflate(R.layout.item_shangpin, null);
	// ImageView Img = (ImageView) view.findViewById(R.id.img_logo);
	// x.image().bind(Img, getList().get(position));
	// return view;
	// }

	@Override
	protected void convert(BaseAdapterHelper arg0, final ShangpinShoucang arg1) {
		if(arg1.edittime.equals("null") == false && arg1.edittime.equals("") == false){
			arg0.setText(R.id.tv_time, DateKit.dateToStr(new Date(Long.parseLong(arg1.edittime)*1000)));
		}
		arg0.setText(R.id.tv_title, arg1.title)
				.setText(R.id.tv_progress, arg1.percent + "%").setText(R.id.tv_jine, arg1.total_money + "Ԫ")
				.setText(R.id.tv_number, arg1.number);
		ProgressBar progressBar = arg0.getView(R.id.pb);
		ImageView img_logo = arg0.getView(R.id.img_logo);
		progressBar.setMax(100);
		progressBar.setProgress(Math.round(Float.parseFloat(arg1.percent)));
		x.image().bind(img_logo, arg1.thumb);
		arg0.setOnClickListener(R.id.btn_xiangqing, new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, Act_PaipaibaoDetail.class);
				intent.putExtra("itemid", arg1.itemid);
				context.startActivity(intent);
			}
		});
	}

}
